﻿using Anke.SHManage.BLL;
using Anke.SHManage.MSSQLDAL;
using Microsoft.Reporting.WebForms;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Anke.SHManage.Web.Reports
{
    public partial class LS_SurplusListPrintWebForm : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                InitPage();
            }
        }

        private void InitPage()
        {
            BindReportDataSource();
        }
        protected void BindReportDataSource()
        {
            //string aspxUrl = "~/Reports/LS_SurplusListPrintWebForm.aspx?SurplusCode=" + SurplusCode + "&MaterialType=" + MaterialType + "&MaterialID=" + MaterialID;
            List<int> listStorageCode = new List<int>();

            string SurplusCode = Request.QueryString["SurplusCode"].ToString();
            string MaterialType = Request.QueryString["MaterialType"].ToString();
            List<string> mTypeList = UserOperateContext.Current.getMaterialTypeList(MaterialType);
            string MaterialID = Request.QueryString["MaterialID"].ToString();
            if (SurplusCode.Length > 0)
                listStorageCode.Add(int.Parse(SurplusCode));
            else
                listStorageCode = UserOperateContext.Current.Session_StorageRelated.listUserStorage;

            this.ReportViewer1.LocalReport.DataSources.Clear();
            this.ReportViewer1.LocalReport.ReportPath = Server.MapPath(@"~/Reports/LS_XSurplusList.rdlc");

            I_SurplusDAL dal = new I_SurplusDAL();

            DataTable dt7 = dal.GetSurplusListPrint(MaterialID, listStorageCode, mTypeList);
            this.ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSetForSurplusPrint", dt7));
            this.ReportViewer1.LocalReport.Refresh();
        }

    }
}